<?php
	header("Content-type: text/html; charset=utf-8");
	header("Access-Control-Allow-Origin: *");
	include("TopClient.php");
	include("PictureUploadRequest.php");
	$appkey = "21325157";
	$secret = "28637da964f85fd563e5c7ef5db7397c";
	$sessionKey = $_GET["access_token"];
	$title = $_GET["title"];
	$c = new TopClient;
	$c->appkey = $appkey;
	$c->secretKey = $secret;

	$req = new PictureUploadRequest;
	$req->setPictureCategoryId(0);
	//附件上传的机制参见PHP CURL文档，在文件路径前加@符号即可
	$req->setImg("@".$_FILES['userfile']["tmp_name"]);
	$req->setImageInputTitle("Test.jpg");
	$req->setTitle($title);
	$resp = $c->execute($req, $sessionKey);
	$data = json_encode($resp);
	echo $data;